home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / DR1.#1 PowerPlant ƒ / LWindow.h < prev    next >
Text File  |  1994-02-10  |  5KB  |  176 lines

  1. // ===========================================================================
  2. //    LWindow.h                         ©1993 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4.  
  5. #pragma once
  6.  
  7. #include "LView.h"
  8. #include "LCommander.h"
  9. #include "LModelObject.h"
  10.  
  11.  
  12. typedef struct    SWINDResource {        // Format of a 'WIND' Resource
  13.     Rect    bounds;
  14.     Int16    procID;
  15.     Int16    visible;
  16.     Int16    hasGoAway;
  17.     Int32    refCon;
  18.     Str255    title;                    // Not really, but OK as long as we
  19.                                     //   only use this for typecasting
  20.                                     //   WIND resource handles
  21. } SWINDResource, *SWINDResourceP, **SWINDResourceH;
  22.  
  23.  
  24. enum {
  25.     windAttr_CloseBox        = 0x8000,
  26.     windAttr_TitleBar        = 0x4000,
  27.     windAttr_Floating        = 0x2000,
  28.     windAttr_Modal            = 0x1000,
  29.     windAttr_Resizable        = 0x0800,
  30.     windAttr_SizeBox        = 0x0400,
  31.     windAttr_Zoomable        = 0x0200,
  32.     windAttr_Regular        = 0x0100,
  33.     windAttr_ShowNew        = 0x0080,
  34.     windAttr_Enabled        = 0x0040,
  35.     windAttr_Targetable        = 0x0020,
  36.     windAttr_GetSelectClick    = 0x0010,
  37.     windAttr_HideOnSuspend    = 0x0008,
  38.     windAttr_DelaySelect    = 0x0004,
  39.     windAttr_EraseOnUpdate    = 0x0002
  40. };
  41.  
  42. typedef    Uint16    EWindAttr;
  43.  
  44. const Int16        PP_Window_Kind = 20000;
  45. const Int16        click_OutsideModal = 42;
  46.  
  47. #define        window_InFront    ((WindowPtr) -1)
  48. #define        window_InBack    ((WindowPtr) 0)
  49.  
  50.  
  51. class    LWindow : public LView, public LCommander, public LModelObject {
  52.  
  53. public:
  54.                     LWindow();
  55.     virtual            ~LWindow();
  56.     
  57.     static LWindow*    CreateWindow(ResIDT inWindowID,
  58.                                 LCommander *inSuperCommander);
  59.     static LWindow*    CreateWindowStream(LStream *inStream);
  60.                     LWindow(LStream *inStream);
  61.     
  62.     void            MakeMacWindow(short inWINDid);
  63.     
  64.     static LWindow*    FetchWindowObject(WindowPtr inWindowP);
  65.     virtual GrafPtr    GetMacPort() const;
  66.     
  67.     Boolean            HasAttribute(EWindAttr inAttribute) const;
  68.  
  69.     void            GetMinMaxSize(Rect &outRect) const;
  70.     void            SetMinMaxSize(const Rect &inRect);
  71.     
  72.     void            GetStandardSize(SDimension16 &outStdSize);
  73.     void            SetStandardSize(SDimension16 inStdSize);
  74.     
  75.     virtual StringPtr    GetDescriptor(Str255 outDescriptor) const;
  76.     virtual void        SetDescriptor(ConstStr255Param inDescriptor);
  77.     
  78.     virtual void    HandleClick(const EventRecord& inMacEvent, Int16 inPart);
  79.     virtual void    ClickInContent(const EventRecord& inMacEvent);
  80.     
  81.     virtual void    UpdatePort();
  82.     virtual void    EstablishPort();
  83.     
  84.     virtual void    InvalPortRect(const Rect *inRect);
  85.     virtual void    InvalPortRgn(RgnHandle inRgnH);
  86.     virtual void    ValidPortRect(const Rect *inRect);
  87.     virtual void    ValidPortRgn(RgnHandle inRgnH);
  88.  
  89.     void            Select();
  90.     virtual void    Show();
  91.     virtual void    Activate();
  92.     virtual void    Deactivate();
  93.     virtual void    Enable();
  94.     
  95.     virtual void    Suspend();
  96.     virtual void    Resume();
  97.     
  98.     virtual void    GlobalToPortPoint(Point &ioPoint) const;
  99.     virtual void    PortToGlobalPoint(Point &ioPoint) const;
  100.  
  101.     virtual Boolean    ObeyCommand(CommandT inCommand, void *ioParam);
  102.     virtual void    FindCommandStatus(CommandT inCommand,
  103.                             Boolean &outEnabled, Boolean &outUsesMark,
  104.                             Char16 &outMark);
  105.  
  106.         // •• Performing Actions
  107.         
  108.             // • Changing Position
  109.     
  110.     virtual void    ClickInDrag(const EventRecord& inMacEvent);
  111.     void            SendAESetPosition(Point inPosition, Boolean inExecuteAE);
  112.     void            DoSetPosition(Point inPosition);
  113.     
  114.             // • Changing Size and/or Position
  115.     
  116.     virtual void    ClickInGrow(const EventRecord& inMacEvent);
  117.     virtual void    SendAESetBounds(Rect *inBounds, Boolean inExecuteAE);
  118.     void            DoSetBounds(const Rect &inBounds);
  119.     
  120.             // • Zooming
  121.     virtual void    ClickInZoom(const EventRecord& inMacEvent,
  122.                             short inZoomDirection);
  123.     virtual Boolean    CalcStandardBounds(Rect &outStdBounds) const;
  124.     virtual void    CalcStandardBoundsForScreen(const Rect &inScreenBounds,
  125.                             Rect &outStdBounds) const;
  126.     virtual void    SendAESetZoom();
  127.     virtual void    DoSetZoom(Boolean inZoomToStdState);
  128.     
  129.             // • Closing
  130.         
  131.     virtual void    ClickInGoAway(const EventRecord& inMacEvent);
  132.     virtual void    SendAEClose();
  133.     virtual OSErr    DoAEClose();
  134.     
  135.         // •• AppleEvent Object Model Support ••
  136.     
  137.     DescType                GetModelKind() const;
  138.     virtual void            MakeSelfSpecifier(AEDesc& inSuperSpecifier,
  139.                                               AEDesc& outSelfSpecifier) const;
  140.                                               
  141.     virtual LModelProperty*    GetModelProperty(DescType inProperty);
  142.     virtual void            GetAEProperty(DescType inProperty,
  143.                                           const AEDesc& inRequestedType,
  144.                                           AEDesc& outPropertyDesc) const;
  145.     virtual void            SetAEProperty(DescType inProperty,
  146.                                           const AEDesc& inValue,
  147.                                           AEDesc& outAEReply);
  148.     void                    GetAEWindowAttribute(Uint16 inAttribute,
  149.                                           AEDesc& outPropertyDesc) const;
  150.  
  151.     virtual void            HandleAppleEvent(const AppleEvent& inAppleEvent,
  152.                                              AppleEvent& outARReply,
  153.                                              long inAENumber);
  154.                                              
  155.     static WindowPtr    FindNthWindow(Int16 inN);
  156.     static Int16        FindWindowIndex(WindowPtr inWindowP);
  157.  
  158. protected:
  159.     virtual void    DrawSelf();
  160.     void            DrawSizeBox();
  161.     
  162.     virtual void    ShowSelf();
  163.     virtual void    HideSelf();
  164.     
  165.     virtual void    ActivateSelf();
  166.     virtual void    DeactivateSelf();
  167.     
  168. private:
  169.     WindowPtr        mMacWindowP;
  170.     Rect            mMinMaxSize;
  171.     SDimension16    mStandardSize;
  172.     Rect            mUserBounds;
  173.     Uint16            mAttributes;
  174.     Boolean            mMoveOnlyUserZoom;
  175. };
  176.